﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Bigeagle.Portable.BoardGames;
using Bigeagle.Portable.BoardGames.Go;
namespace TestKiFUGame
{
    class Program
    {
        static string fileName = @"C:\Users\bigeagle\Documents\百度云\KiFU\btjs_03.sgf";
        //static string fileName = @"C:\Users\云鹏\Documents\百度云\KiFU\btjs_03.sgf";
        //static string outputFile = @"c:\temp\aaa.sgf" ;
        static void Main(string[] args)
        {
            try
            {
                using (Stream sr = File.OpenRead(fileName))
                {
                    //string str = sr.ReadToEnd();
                    //sr.Close();
                    SGFKiFUSerializer serializer = new SGFKiFUSerializer();
                    serializer.KiFUEncoding = Encoding.GetEncoding("gb2312");
                    GoGameInfo gameInfo = serializer.ReadGameInfo(sr);
                    Console.WriteLine("name:{0}", gameInfo.Name);
                    Console.WriteLine("black:{0}", gameInfo.BlackPlayer.Name);
                    Console.WriteLine("white:{0}", gameInfo.WhitePlayer.Name);
                    Console.WriteLine("result :{0}", gameInfo.Result.ChineseString);
                    sr.Close();
                    //KiFUGame game = serializer.DeSerialize(str);
                    //if (game != null)
                    //{
                    //    Console.WriteLine("棋局名称：{0}", game.Name);
                    //    Console.WriteLine("说明：{0}", game.Comment);
                    //    Console.WriteLine("手数：{0}", game.Moves.Count);

                    //    List<CommentsMove> moves = game.GetActualPlayMoves();
                    //    foreach (CommentsMove move in moves)
                    //    {
                    //        Console.WriteLine("[{0}]{1}[{2},{3}]{4}"
                    //            , move.Step, move.Side, move.X, move.Y, move.Comment);
                    //    }
                    //}

                    ////写棋谱
                    //using (StreamWriter sw = new StreamWriter(outputFile, false, Encoding.GetEncoding("gb2312")))
                    //{
                    //    sw.Write(serializer.Serialize(game));
                    //    sw.Flush();
                    //    sw.Close();
                    //}

                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("press ay key to exit.");
            Console.Read();
        }

    }//end class
}//end namespace
